from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QVBoxLayout
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import pyqtSlot
import sys


def init_widget(w: QWidget):
    # 3. 设置窗口内容
    w.setWindowTitle("嵌套布局")
    # w.resize(500, 300)
    
    # 创建水平布局 Horizontal
    layout = QHBoxLayout()
    # 设置到window
    w.setLayout(layout)
    
    layout1 = QVBoxLayout()
    layout1.addWidget(QPushButton("1"))
    
    layout2 = QVBoxLayout()
    layout2.addWidget(QPushButton("2"))
    layout2.addWidget(QPushButton("3"))
    
    layout3 = QVBoxLayout()
    layout3.addWidget(QPushButton("4"))
    layout3.addWidget(QPushButton("5"))
    layout3.addWidget(QPushButton("6"))
    
    layout4 = QVBoxLayout()
    layout4.addWidget(QPushButton("7"))
    layout4.addWidget(QPushButton("8"))
    layout4.addWidget(QPushButton("9"))
    layout4.addWidget(QPushButton("10"))
    
    
    layout.addLayout(layout1)
    layout.addLayout(layout2)
    layout.addLayout(layout3)
    layout.addLayout(layout4)

if __name__ == '__main__':
    # 1. 创建应用程序
    app = QApplication(sys.argv)
    # 2. 创建窗口
    w = QWidget()
    # ------------------------------------------------
    init_widget(w)
    # ------------------------------------------------
    # 4. 显示窗口
    w.show()
    # 5. 等待关闭
    sys.exit(app.exec_())